[TypeDeclaration] Handle fallback from param same type object on ReturnTypeFromReturnNewRector#5039
[TypeDeclaration] Handle fallback from param same type object on ReturnTypeFromReturnNewRector#5039samsonasik merged 11 commits intomainfrom
Conversation
|
implemented 🎉 |
|
@TomasVotruba the phpstan notice seems due to new |
|
@TomasVotruba I created PR to symplify/phpstan-extensions to revert realpath: |
|
|
||
| final class FallbackFromParamSelf | ||
| { | ||
| public function action(self $obj): \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\Fixture\FallbackFromParamSelf |
There was a problem hiding this comment.
Do we need another test for a static and/or parent typed param?
There was a problem hiding this comment.
static already error on the first place :)
There was a problem hiding this comment.
multiple return already skipped at
|
I updated to use |
|
All checks have passed 🎉 @TomasVotruba I think it is ready. |
| // not file | ||
| && ! is_file($skipRule) | ||
| // a Rector end | ||
| && str_ends_with($skipRule, 'Rector') |
There was a problem hiding this comment.
We should do this cheap chrck earlier
|
All checks have passed 🎉 @TomasVotruba I am merging it to have faster feedback to test ;) |
| /** @var string|false $setRealpath */ | ||
| $setRealpath = realpath($setFile); | ||
| $setRealpath = (string) $setRealpath; | ||
| $relativeFilePath = Strings::after($setRealpath, getcwd() . '/'); |
There was a problem hiding this comment.
This will be always string, as we use existing set paths:
$setRealpath = realpath($setFile);
$relativeFilePath = Strings::after($setRealpath, getcwd() . '/');There was a problem hiding this comment.
sure, I updated at :
There was a problem hiding this comment.
the php process might still not be able to read this file (e.g. because of filesystem persmissions) and return false?
There was a problem hiding this comment.
@staabm that's what I thought, but since tools/ directory is not shipped to rector/rector, I guess it safe for user, the concern is probably when directory/set removed in the future and not detected.
The better solution is probably use:
Assert::string($setRealpath);so it will be detected early when path removed/renamed.
|
Thanks 🙏 |
@staabm this is to handle fallback from param on return new object: